﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utils.EventAggregator;

namespace Churchtoolkit.Utils.RulesManager
{
    public class EntityAction : BaseEvent<EntityActionEventArgs>
    {
        public SubscriptionToken Subscribe<T>(Action<EntityActionEventArgs<T>> action)
        {
            return base.Subscribe(e => action((EntityActionEventArgs<T>)e));
        }
    }
    public abstract class EntityActionEventArgs
    {
        public object Entity { set; get; }

        public EntityState State { protected set; get; }
    }

    public class EntityActionEventArgs<TEntity> : EntityActionEventArgs
    {
        public EntityActionEventArgs(EntityState state,TEntity entity)
        {
            base.Entity = entity;
            base.State = state;
        }
        public new TEntity Entity { get { return (TEntity)base.Entity; } }
    }
}
